//
//  Num+Ext.swift
//  KLExtension
//
//  Created by nkl on 2023/6/29.
//

import Foundation

extension Int {
    ///随机数
    public static func random(in range: ClosedRange<Int>, excluding x: Int) -> Int {
        if range.contains(x) {
            let r = Int.random(in: Range(uncheckedBounds: (range.lowerBound, range.upperBound)))
            return r == x ? range.upperBound : r
        } else {
            return Int.random(in: range)
        }
    }
}
